package mytest;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * 
 * @author Administrator
 *
 *2 2
01
10

result:1


3 5
01000
00100
00001

result:3

8 11
10000000000
00100000000
00000001000
00000000000
00000000000
00000000000
00000000100
00000000000

result:16

3 9
000000000
000010000
000000000

result:0


12 30
...1..........................
............................1.
.1............................
............1.................
.................1............
......................1.......
......1.......................
....1.........................
...............1..............
.......................1......
...........................1..
.......1......................

result:99

 *
 *
 */


public class TopCoder1 {

	static boolean arr[][]=new boolean[51][51];
	
	static boolean dpx[]=new boolean[51];
	static int cntx,cnty;
	static boolean dpy[]=new boolean[51];
	
	static int f[]=new int[51];
	static int b[]=new int[51];
	static int N,M;
	
	static int solve()
	{
		for(int i=0;i<N;i++)
			for(int j=0;j<M;j++)
			{
				if(arr[i][j])
				{
					dpx[i]=true;
					dpy[j]=true;
				}
			}
		
		int sumx=0,sumy=0;
		for(int i=0;i<N;i++)
		{
			sumx+=cntx;
			if(dpx[i])
			{
				cntx++;
			}
			f[i]=sumx;
		}
		cntx=0;sumx=0;
		for(int i=N-1;i>=0;i--)
		{
			sumx+=cntx;
			if(dpx[i])
			{
				cntx++;
			}
			b[i]=sumx;
		}
		
		int minx=f[0]+b[0];
		for(int i=1;i<N;i++)
		{
			if(minx>f[i]+b[i])
			{
				minx=f[i]+b[i];
			}
		}
		
		cnty=0;sumy=0;
		for(int i=0;i<M;i++)
		{
			if(dpy[i])
			{
				f[i]=sumy;
				cnty++;
			}else{
				sumy+=cnty;
				f[i]=sumy;
			}
		}
		cnty=0;sumy=0;
		for(int i=M-1;i>=0;i--)
		{
			if(dpy[i])
			{
				b[i]=sumy;
				cnty++;
			}else{
				sumy+=cnty;
				b[i]=sumy;
			}
		}
		
		int miny=f[0]+b[0];
		
		for(int i=1;i<M;i++)
		{
			if(miny>f[i]+b[i])
			{
				miny=f[i]+b[i];
			}
		}
		
		System.out.println(minx+","+miny);
		return minx+miny;
	}
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {

		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer st=new StringTokenizer(bf.readLine());
		N=Integer.parseInt(st.nextToken());
		M=Integer.parseInt(st.nextToken());
		for(int i=0;i<N;i++)
		{
			String line=bf.readLine();
			for(int j=0;j<M;j++)
			{
				if(line.charAt(j)=='0'||line.charAt(j)=='.')arr[i][j]=false;
				else arr[i][j]=true;
			}
		}
		System.out.println(solve());
	}

}
